/**
 * 参数设置管理初始化
 */
var WhiteShopApply = {
    id: "WhiteShopApplyTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
WhiteShopApply.initColumn = function () {
    var columns = [
        {field: 'selectItem', radio: true},
        {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle',width:'50px'},
        {title: '记录编号', field: 'order_no', align: 'center', valign: 'middle'},
        {title: '用户姓名', field: 'userName', align: 'center', valign: 'middle'},
        {title: '绑定手机', field: 'bindingPhone', align: 'center', valign: 'middle'},
        {title: '推荐人推荐码', field: 'recommendationNo', align: 'center', valign: 'middle'},
        {title: '支付金额', field: 'payMoney', align: 'center', valign: 'middle'},
        {title: '支付方式', field: 'zhifufangshi', align: 'center', valign: 'middle'},
        {title: '支付渠道', field: 'payChannel', align: 'center', valign: 'middle'},
        {title: '缴费回执号', field: 'flowNo', align: 'center', valign: 'middle'},
        {title: '支付时间', field: 'payTime', align: 'center', valign: 'middle'},
        {title: '收款账号', field: 'rec_platform', align: 'center', valign: 'middle'},
        {title: '状态', field: 'zhuangtai', align: 'center', valign: 'middle'},
        {title: '创建时间', field: 'applyTime', align: 'center',sortable: true, valign: 'middle'}
    ]
    return columns;
};

/**
 * 检查是否选中
 */
WhiteShopApply.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        PartnerApply.seItem = selected[0];
        return true;
    }
};


/**
 * 点击添加合伙人
 */
WhiteShopApply.WhiteShopApplyAdd = function () {

    var index = layer.open({
        type: 2,
        title: '手动新增入百星',
        area: ['1000px', '600px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/partnerApply/whiteShopApply_add'
    });
    this.layerIndex = index;
};

/**
 * 查询参数设置列表
 */
WhiteShopApply.search = function () {
    var queryData = {};
    queryData['payStatus'] = $("#payStatus").val();
    queryData['recommendation_no'] = $("#recommendation_no").val();
    queryData['applytime'] = $("#applytime").val().replace("/","-");
    if($("#applytime").val() != "") {
        if($("#applytime_end").val() == "") {
            Feng.info("请选择结束时间！");
            return false;
        }else{
            queryData['applytime_end'] = $("#applytime_end").val().replace("/","-");
        }
    }
    WhiteShopApply.table.refresh({query: queryData});
};


/**
 * 导出
 */
WhiteShopApply.excel = function () {
	 var url = "/partnerApply/excelWhiteShopList?";
	 if($("#payStatus").val()!="")
	 {
		 url = url+"payStatus="+$("#payStatus").val();
	 }
	 if($("#recommendation_no").val()!="")
	 {
		 url = url+"&recommendation_no="+$("#recommendation_no").val();
	 }
	if($("#applytime").val()!="")
	{
		 url = url+"&applytime="+$("#applytime").val().replace("/","-");
	}
	    if($("#applytime").val() != "") {
	        if($("#applytime_end").val() == "") {
	            Feng.info("请选择结束时间！");
	            return false;
	        }else{
	        	 url = url+"&applytime_end="+$("#applytime_end").val().replace("/","-");
	        }
	    }
	 window.location.href=url;
};

/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
WhiteShopApply.formParams = function() {
    var queryData = {};
    queryData['loginAccount'] = $("#loginAccount").val();
    return queryData;
}

$(function () {
    $("#applytime").attr('type','date');
    $("#applytime_end").attr('type','date');
    var defaultColunms = WhiteShopApply.initColumn();
    var table = new BSTable(WhiteShopApply.id, "/partnerApply/whiteShopList", defaultColunms);
    table.setPaginationType("client");
    WhiteShopApply.table = table.init();
});
